Telegram Group & Telegram Channel
Обычно для группировки массива по какому-то ключу используют reduce

Однако уже доступны Object.groupBy и Map.groupBy, которые позволяют упростить эту процедуру

const users = [
{ id: 1, name: "Alex", role: "admin" },
{ id: 2, name: "Anna", role: "user" },
];

const grouped = Object.groupBy(users, ({ role }) => role);

// Результат:
// { admin: [{...}], user: [{...}] }


#js



tg-me.com/vuefaq/1201
Create:
Last Update:

Обычно для группировки массива по какому-то ключу используют reduce

Однако уже доступны Object.groupBy и Map.groupBy, которые позволяют упростить эту процедуру

const users = [
{ id: 1, name: "Alex", role: "admin" },
{ id: 2, name: "Anna", role: "user" },
];

const grouped = Object.groupBy(users, ({ role }) => role);

// Результат:
// { admin: [{...}], user: [{...}] }


#js

BY Vue-FAQ


Warning: Undefined variable $i in /var/www/tg-me/post.php on line 283

Share with your friend now:
tg-me.com/vuefaq/1201

View MORE
Open in Telegram


Vue FAQ Telegram | DID YOU KNOW?

Date: |

The S&P 500 slumped 1.8% on Monday and Tuesday, thanks to China Evergrande, the Chinese property company that looks like it is ready to default on its more-than $300 billion in debt. Cries of the next Lehman Brothers—or maybe the next Silverado?—echoed through the canyons of Wall Street as investors prepared for the worst.

Telegram announces Search Filters

With the help of the Search Filters option, users can now filter search results by type. They can do that by using the new tabs: Media, Links, Files and others. Searches can be done based on the particular time period like by typing in the date or even “Yesterday”. If users type in the name of a person, group, channel or bot, an extra filter will be applied to the searches.

Vue FAQ from br


Telegram Vue-FAQ
FROM USA